Ext.define('IHC.controller.ihc.cadastros.IHC001DetailListController', {
    extend : 'Ext.app.Controller',

    requires : [
        'IHC.model.Atividade', 
        'IHC.store.ihc.cadastros.IHC001Atividade', 
        'IHC.view.ihc.cadastros.IHC001DetailListView'
    ],

    stores : [
        'IHC.store.ihc.cadastros.IHC001Atividade'
    ],

    models : [
        'IHC.model.Atividade'
    ],

    views : [
        'IHC.view.ihc.cadastros.IHC001DetailListView'
    ],
    
    formModule : 'IHC.controller.ihc.cadastros',
    
    formName : 'IHC001',
    
    suffixName : 'Detail',
    
    mixins : [
        'InsoftExtUi.ux.mixins.controller.CrudDetailListMixin'
    ],
    
    refs : [{
        selector : 'ihc001-detail-list',
        xtype : 'ihc001-detail-list',
        ref : 'mainGrid',
        autoCreate : true
    }],
    
    init : function() {
        var me = this;
    
        if (!me.inited) {
            me.bindDefaultActions('#ihc001-detail-list');
            me.bindMasterRecordEvents('#IHC.controller.ihc.cadastros.IHC001ListController');
            me.recordStore = me.getStore('IHC.store.ihc.cadastros.IHC001Atividade');
        }

        me.inited = true;
    },
    
    populateDetails : function() {
        var me = this;
        me.setDefaultFilter(me.masterRecord);
        me.recordStore.load();
    },
    
    setDefaultFilter : function(masterRecord) {
        var me = this;
        
        if (masterRecord) {
            me.recordStore.proxy.extraParams = {
                'extraFilter.projeto.id': masterRecord.get('id')
            };
        } else {
            me.recordStore.proxy.extraParams = {
                'extraFilter.projeto.id': -1
            };
        }
    },
    
    actionIndex : function() {
        var me = this, 
            manager = me.getLocaleManager(), 
            title = manager.get('ihc001-detail.mainPanel.title');
        me.setDefaultFilter(null);
        me.recordStore.load();
    }
});
